from django.http import JsonResponse
from django.http import HttpResponse
from django.contrib.auth.decorators import login_required
from django.shortcuts import render, redirect
import hashlib
import json
from ClassCongregation import VulnerabilityInquire



def register(request):

    if request.method == "POST":
        try:
            UserToken=json.loads(request.body)["token"]
            #UserToken=request.POST.get('token', None).strip("\r\n")
            if UserToken!=None:
                result=VulnerabilityInquire().Inquire(UserToken)
                if len(result)>0:
                    return HttpResponse(result)
                else:
                    return JsonResponse({'message': '没找到数据', 'code': 200, })
        except:
            return JsonResponse({'message': 'Token不能为空', 'code': 500, })
    else:
        return JsonResponse({'message': '请使用Get请求', 'code': 500, })


